package com.example.mallsystem1104.controller;

import com.example.mallsystem1104.common.Result;
import com.example.mallsystem1104.entity.User;
import com.example.mallsystem1104.utils.TokenUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author zy
 * @Date 2024/12/12 11:07
 * @packageName:com.example.mallsystem1104.controller
 * @ClassName:RoleController
 */
@RestController
public class RoleController {

    //获取当前用户的角色
    @PostMapping("/role")
    public Result getUserRole(){
        //从token中获取当前用户
        User currentUser= TokenUtils.getCurrentUser();
        return Result.success(currentUser.getRole());
    }
}
